package com.orange.score.model.index;

import android.util.Log;
import com.orange.score.constants.ScoreType;
import com.orange.score.model.league.League;
import com.orange.score.model.league.LeagueManager;
import com.orange.score.model.match.Match;
import com.orange.score.utils.DateUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class OddsManager
{
  private static String TAG = OddsManager.class.getName();
  List<DaxiaoOdds> daxiaoOddsList;
  List<String> filterLeagueIdList;
  ScoreType filterScoreType;
  List<Match> matchList = new ArrayList();
  Map<String, Match> matchMap = new HashMap();
  Map<String, Odds> oddsMap;
  List<OupeiOdds> oupeiOddsList;
  List<YapeiOdds> yapeiOddsList = new ArrayList();

  public OddsManager()
  {
    this.oupeiOddsList = new ArrayList();
    this.daxiaoOddsList = new ArrayList();
    this.filterLeagueIdList = new ArrayList();
    this.oddsMap = new HashMap();
    this.filterScoreType = ScoreType.FIRST;
  }

  private boolean isChineseTodayString(String paramString)
  {
    int i;
    if (paramString.equals(DateUtil.dateToStringByFormat(new Date(), "yyyy-MM-dd")))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public void addOddsToMap(Odds paramOdds, Map<Match, List<Odds>> paramMap)
  {
    Object localObject;
    Match localMatch = findMatchById(paramOdds.getMatchId());
    if ((localMatch != null) && (paramOdds != null))
    {
      if (paramMap.containsKey(localMatch))
        break label56;
      localObject = new ArrayList();
      ((List)localObject).add(paramOdds);
    }
    while (true)
    {
      paramMap.put(localMatch, localObject);
      return;
      label56: localObject = (List)paramMap.get(localMatch);
      ((List)localObject).add(paramOdds);
    }
  }

  public boolean canDisplayOdds(Match paramMatch, String paramString)
  {
    int i;
    if (!(isChineseTodayString(paramString)))
      i = 1;
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return i;
          if (paramMatch != null)
            break;
          i = 0;
        }
        if (paramMatch.getStatus() != -1)
          break;
        i = 0;
      }
      i = 1;
    }
  }

  public Odds filterOdds(String paramString1, String paramString2, OddsType paramOddsType)
  {
    Object localObject;
    switch ($SWITCH_TABLE$com$orange$score$model$index$OddsType()[paramOddsType.ordinal()])
    {
    default:
      localObject = null;
    case 1:
    case 3:
    case 2:
    }
    while (true)
    {
      DaxiaoOdds localDaxiaoOdds;
      while (true)
      {
        OupeiOdds localOupeiOdds;
        while (true)
        {
          YapeiOdds localYapeiOdds;
          return localObject;
          Iterator localIterator3 = this.yapeiOddsList.iterator();
          do
          {
            if (!(localIterator3.hasNext()));
            localYapeiOdds = (YapeiOdds)localIterator3.next();
          }
          while ((!(localYapeiOdds.getCompanyId().equals(paramString2))) || (!(localYapeiOdds.getMatchId().equals(paramString1))));
          localObject = localYapeiOdds;
        }
        Iterator localIterator2 = this.oupeiOddsList.iterator();
        do
        {
          if (!(localIterator2.hasNext()));
          localOupeiOdds = (OupeiOdds)localIterator2.next();
        }
        while ((!(localOupeiOdds.getCompanyId().equals(paramString2))) || (!(localOupeiOdds.getMatchId().equals(paramString1))));
        localObject = localOupeiOdds;
      }
      Iterator localIterator1 = this.daxiaoOddsList.iterator();
      do
      {
        if (!(localIterator1.hasNext()));
        localDaxiaoOdds = (DaxiaoOdds)localIterator1.next();
      }
      while ((!(localDaxiaoOdds.getCompanyId().equals(paramString2))) || (!(localDaxiaoOdds.getMatchId().equals(paramString1))));
      localObject = localDaxiaoOdds;
    }
  }

  public Map<Match, List<Odds>> filterOddsByOddsType(OddsType paramOddsType)
  {
    HashMap localHashMap = new HashMap();
    switch ($SWITCH_TABLE$com$orange$score$model$index$OddsType()[paramOddsType.ordinal()])
    {
    default:
      return localHashMap;
    case 1:
      Iterator localIterator3 = this.yapeiOddsList.iterator();
      while (true)
      {
        Odds localOdds3;
        do
        {
          if (!(localIterator3.hasNext()));
          localOdds3 = (Odds)localIterator3.next();
        }
        while (!(this.filterLeagueIdList.contains(getLeagueIdByMatchId(localOdds3.getMatchId()))));
        addOddsToMap(localOdds3, localHashMap);
      }
    case 3:
      Iterator localIterator2 = this.oupeiOddsList.iterator();
      while (true)
      {
        Odds localOdds2;
        do
        {
          if (!(localIterator2.hasNext()));
          localOdds2 = (Odds)localIterator2.next();
        }
        while (!(this.filterLeagueIdList.contains(getLeagueIdByMatchId(localOdds2.getMatchId()))));
        addOddsToMap(localOdds2, localHashMap);
      }
    case 2:
    }
    Iterator localIterator1 = this.daxiaoOddsList.iterator();
    while (true)
    {
      Odds localOdds1;
      do
      {
        if (!(localIterator1.hasNext()));
        localOdds1 = (Odds)localIterator1.next();
      }
      while (!(this.filterLeagueIdList.contains(getLeagueIdByMatchId(localOdds1.getMatchId()))));
      addOddsToMap(localOdds1, localHashMap);
    }
  }

  public Match findMatchById(String paramString)
  {
    return ((Match)this.matchMap.get(paramString));
  }

  public List<String> getFilterLeagueIdList()
  {
    return this.filterLeagueIdList;
  }

  public ScoreType getFilterScoreType()
  {
    return this.filterScoreType;
  }

  public String getLeagueIdByMatchId(String paramString)
  {
    String str;
    if ((paramString == null) || (paramString.length() == 0))
      str = null;
    while (true)
    {
      Match localMatch;
      return str;
      Iterator localIterator = this.matchList.iterator();
      do
      {
        while (!(localIterator.hasNext()))
          str = null;
        localMatch = (Match)localIterator.next();
      }
      while (!(localMatch.getMatchId().equals(paramString)));
      str = localMatch.getLeagueId();
    }
  }

  public Set<Odds> getOddsUpdateSet(List<String[]> paramList, OddsType paramOddsType)
  {
    Object localObject;
    HashSet localHashSet;
    int i;
    String str3;
    String str4;
    String str5;
    Odds localOdds;
    if ((paramList == null) || (paramList.size() == 0))
      localObject = null;
    while (true)
    {
      return localObject;
      localHashSet = new HashSet();
      i = 0;
      if (i < paramList.size())
        break;
      Log.d(TAG, "total update odds count = " + localHashSet.size());
      localObject = localHashSet;
    }
    String[] arrayOfString = (String[])paramList.get(i);
    if (arrayOfString.length < 5)
      Log.w(TAG, "getOddsUpdateSet but field count not enough, count = " + arrayOfString.length);
    do
    {
      while (true)
        ++i;
      String str1 = arrayOfString[0];
      String str2 = arrayOfString[1];
      str3 = arrayOfString[3];
      str4 = arrayOfString[4];
      str5 = arrayOfString[2];
      localOdds = filterOdds(str1, str2, paramOddsType);
    }
    while (localOdds == null);
    switch ($SWITCH_TABLE$com$orange$score$model$index$OddsType()[paramOddsType.ordinal()])
    {
    default:
    case 1:
    case 3:
    case 2:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            if ((localOdds.homeTeamOddsFlag == 0) && (localOdds.awayTeamOddsFlag == 0) && (localOdds.pankouFlag == 0));
            localHashSet.add(localOdds);
          }
          ((YapeiOdds)localOdds).updateOdds(str3, str4, str5);
        }
        ((OupeiOdds)localOdds).updateOdds(str3, str4, str5);
      }
      ((DaxiaoOdds)localOdds).updateOdds(str3, str4, str5);
    }
  }

  public void setFilterLeagueIdList(List<String> paramList)
  {
    this.filterLeagueIdList = paramList;
  }

  public void setFilterScoreType(ScoreType paramScoreType)
  {
    if (this.filterScoreType != paramScoreType)
      this.filterLeagueIdList.clear();
    this.filterScoreType = paramScoreType;
  }

  public void updateOddsMatchDataFromStringList(String[] paramArrayOfString, LeagueManager paramLeagueManager)
  {
    int i;
    if ((paramArrayOfString == null) || (paramArrayOfString.length == 0));
    do
    {
      return;
      this.matchList.clear();
      this.matchMap.clear();
      i = 0;
    }
    while (i >= paramArrayOfString.length);
    String[] arrayOfString = paramArrayOfString[i].split("\\^");
    if (arrayOfString.length < 8)
      Log.w(TAG, "updateOddsMatchDataFromStringList but field count not enough, count = " + arrayOfString.length);
    while (true)
    {
      Match localMatch;
      League localLeague;
      do
      {
        while (true)
          ++i;
        String str1 = arrayOfString[0];
        String str2 = arrayOfString[1];
        String str3 = arrayOfString[2];
        String str4 = arrayOfString[3];
        String str5 = arrayOfString[4];
        String str6 = arrayOfString[5];
        String str7 = arrayOfString[6];
        String str8 = arrayOfString[7];
        localMatch = new Match();
        localMatch.setMatchId(str1);
        localMatch.setLeagueId(str2);
        localMatch.setHomeTeamName(str4);
        localMatch.setAwayTeamName(str5);
        localMatch.setMatchTime(str3);
        localMatch.setDate(str3);
        localMatch.setStatus(str6);
        localMatch.setHomeTeamScore(str7);
        localMatch.setAwayTeamScore(str8);
        Log.d(TAG, "add match = " + localMatch.toString());
        this.matchList.add(localMatch);
        this.matchMap.put(str1, localMatch);
        localLeague = paramLeagueManager.findLeagueById(str2);
      }
      while (localLeague == null);
      localMatch.setLeagueName(localLeague.name);
      localLeague.increaseMatchCount();
    }
  }

  public void updateOddsPeilvDataFromStringList(String[] paramArrayOfString, OddsType paramOddsType)
  {
    int i;
    int j;
    if ((paramArrayOfString == null) || (paramArrayOfString.length == 0));
    do
    {
      return;
      this.yapeiOddsList.clear();
      this.oupeiOddsList.clear();
      this.daxiaoOddsList.clear();
      i = paramArrayOfString.length;
      j = 0;
    }
    while (j >= i);
    String[] arrayOfString = paramArrayOfString[j].split("\\^");
    if (arrayOfString.length < 9)
      Log.w(TAG, "updateOddsPeilvDataFromStringList but field count not enough, count = " + arrayOfString.length);
    while (true)
    {
      String str1;
      String str2;
      String str3;
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
              ++j;
            str1 = arrayOfString[0];
            str2 = arrayOfString[1];
            str3 = arrayOfString[2];
            switch ($SWITCH_TABLE$com$orange$score$model$index$OddsType()[paramOddsType.ordinal()])
            {
            default:
            case 1:
            case 3:
            case 2:
            }
          }
          YapeiOdds localYapeiOdds = new YapeiOdds(str1, str2, str3, arrayOfString[3], arrayOfString[4], arrayOfString[5], arrayOfString[6], arrayOfString[7], arrayOfString[8]);
          Log.d(TAG, "add yapeiOdds = " + localYapeiOdds.toString());
          this.yapeiOddsList.add(localYapeiOdds);
        }
        OupeiOdds localOupeiOdds = new OupeiOdds(str1, str2, str3, arrayOfString[3], arrayOfString[4], arrayOfString[5], arrayOfString[6], arrayOfString[7], arrayOfString[8]);
        Log.d(TAG, "add oupeiOdds = " + localOupeiOdds.toString());
        this.oupeiOddsList.add(localOupeiOdds);
      }
      DaxiaoOdds localDaxiaoOdds = new DaxiaoOdds(str1, str2, str3, arrayOfString[3], arrayOfString[4], arrayOfString[5], arrayOfString[6], arrayOfString[7], arrayOfString[8]);
      Log.d(TAG, "add daxiaoOdds = " + localDaxiaoOdds.toString());
      this.daxiaoOddsList.add(localDaxiaoOdds);
    }
  }
}